package com.derive.education_service.common.config;

import com.derive.education_service.common.filter.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册web配置
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(new LoginInterceptor())
                .excludePathPatterns(
                        "/admin/getVerifyCode",
                        "/admin/adminLogin",
                        "/content/getContentById",
                        "/content/getContentList",
                        "/contentRes/getContentResList",
                        "/notice/getNoticeById",
                        "/notice/getNoticeList",
                        "/platform/getPlatformList",
                        "/platform/getPlatformInfoById",
                        "/business/getBusinessListByPlatformId",
                        "/business/getBusinessById",
                        "/registration/addInfoIntention",
                        "/user/addUserInfo",
                        "/user/getUserInfoByOpenId",
                        "/user/upUserInfoById",
                        "/wxapi/*",
                        "/error"); // 白名单
        interceptorRegistration.excludePathPatterns("/**/*.html", "/**/*.jpg", "/**/*.png", "/**/*.jpeg"); // 静态资源白名单 -- 图片加载
    }
}